package top.sqdpt.third.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.sqdpt.third.entity.dto.WeatherRequestDTO;
import top.sqdpt.third.entity.dto.WeatherResponseDTO;
import top.sqdpt.third.enums.WeatherQueryType;
import top.sqdpt.third.factory.WeatherFactory;
import top.sqdpt.third.service.WeatherService;
import top.sqdpt.third.strategy.WeatherStrategy;

import java.util.List;

@Service
public class WeatherServiceImpl implements WeatherService {

    @Autowired
    private WeatherFactory weatherFactory;

    @Override
    public List<WeatherResponseDTO> queryWeather(WeatherQueryType queryType, String address, String city) {
        WeatherStrategy strategyRandom = weatherFactory.getStrategyRandom();
        WeatherRequestDTO weatherRequestDTO = new WeatherRequestDTO(queryType, city, address);
        return strategyRandom.queryWeather(weatherRequestDTO);
    }
}
